package com.hibiscusking.org.controller;

import com.hibiscusking.basic.util.AjaxResult;
import com.hibiscusking.basic.util.PageList;
import com.hibiscusking.org.domain.SystemDictionaryDetail;
import com.hibiscusking.org.domain.SystemDictionaryType;
import com.hibiscusking.org.query.SystemDictionaryDetailQuery;
import com.hibiscusking.org.query.SystemDictionaryTypeQuery;
import com.hibiscusking.org.service.SystemDictionaryDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Id;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/SystemDictionaryDetail")
public class SystemDictionaryDetailController {
    @Autowired
    private SystemDictionaryDetailService systemDictionaryDetailService;
    @GetMapping
    public List<SystemDictionaryDetail> findAllDetail() {
        return systemDictionaryDetailService.findAll();
    }
    @GetMapping("/{id}")
    public List<SystemDictionaryDetail> findAllDetailById(@PathVariable("id") Long id) {
        return systemDictionaryDetailService.findAllDetailById(id);
    }
    @PutMapping
    public PageList<SystemDictionaryDetail> findQuerySystemDictionaryDetail(@RequestBody SystemDictionaryDetailQuery query) {
        return systemDictionaryDetailService.findQuerySystemDictionaryDetail(query);
    }
    @PostMapping
    public AjaxResult saveSystemDictionaryDetail(@RequestBody SystemDictionaryDetail systemDictionaryDetail) {
        if (systemDictionaryDetail.getId() == null) {
            systemDictionaryDetailService.add(systemDictionaryDetail);
        } else {
            systemDictionaryDetailService.update(systemDictionaryDetail);
        }
        return new AjaxResult().success();
    }
    @DeleteMapping("/{id}")
    public AjaxResult deleSystemDictionaryDetailById(@PathVariable("id") Long id) {
        systemDictionaryDetailService.dele(id);
        return new AjaxResult().success();
    }
    @PatchMapping
    public AjaxResult batchdele(@RequestBody List<Long> ids) {
        systemDictionaryDetailService.batchdele(ids);
        return new AjaxResult().success();
    }
}
